<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Markets extends MY_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		$this->load->library('pagination');

		$config['base_url'] = '/manage/markets?';
		
		
		$config['use_page_numbers'] = TRUE;
		//$config['enable_query_strings'] = TRUE;
		$config['page_query_string'] = TRUE;
		$config['query_string_segment'] = 'p';
		$config['first_link'] = '<<';
		$config['last_link'] = '>>';
		$config['prev_link'] = '上一页';
		$config['next_link'] = '下一页';
		//$config['num_tag_open'] = '<li>';
		//$config['num_tag_close'] = '</li>';
		
		//	$config['anchor_class'] = "";
		
		//$rcount=0;

		$this->load->model('Merchant_model');
		$pageindex = 1;
		if($this->input->get('p')!='') $pageindex=$this->input->get('p');

		$recordcount = 0 ;
		$result = $this->Merchant_model->GetListByPagination($pageindex,15,$recordcount);

		

		$config['total_rows'] = $recordcount;
		$config['per_page'] = 3; 
		$this->pagination->initialize($config); 
		$data['pagehtml'] = array('html' => $this->pagination->create_links()); 
		$data['news_list'] = $result;

		//取省数据
		$this->load->model('Areas_model');
		$data['areas_list']  = $this->Areas_model->GetListByParent('');


		$this->load->library('session');
		$data['username'] = $this->session->userdata('username');
		$data['menuindex'] = 3;
		//print($rcount);
		$this->load->view('manage/header', $data);
		$this->load->view('manage/market_index',$data);
		$this->load->view('manage/foot');
	}
}